import { _decorator, Component, Node, Sprite } from 'cc';
import { ResMgr } from '../Mgr/ResMgr';
import { GAMEDATA } from './GAMEDATA';
const { ccclass, property } = _decorator;

export interface MajiangInfo {
    flower: number,
    index: number
}

@ccclass('Majiang')
/**
 * 单张麻将
 */
export class Majiang extends Component {
    //显示卡牌
    @property(Node)
    public Bg: Node = null;

    //更换标记
    @property(Sprite)
    private Sign: Sprite = null;

    //广告层
    @property(Node)
    private AdLoad: Node = null;

    //麻将信息
    public Info: MajiangInfo = { flower: -1, index: -1 };

    /**
     * 更新麻将信息
     */
    public UpdateMajiangInfo(_info: MajiangInfo) {
        this.Info = _info;
        this.AdLoad.active = false;
        this.Sign.node.active = true;
        this.Sign.spriteFrame = ResMgr.Instance.SpriteFrames["majiang_" + GAMEDATA.MAHJONG_STYLE[this.Info.flower] + this.Info.index];
    }

    /**
     * 我是广告
     */
    public IamAd() {
        this.Info = { flower: -1, index: -1 };
        this.Sign.node.active = false;
        this.AdLoad.active = true;
    }



}


